/**
 * Many buttons in a cell http://stackoverflow.com/questions/17565169/unable-to-add-two-buttons-in-a-single-cell-in-a-jtable
 */
package org.tnmk.worktime.gui.tbl;

import java.awt.Component;
import javax.swing.JLabel;
import javax.swing.JTable;
import javax.swing.table.DefaultTableCellRenderer;

/**
 *
 * @author Administrator
 */
public abstract class DecorateDefaultTableCellRenderer extends DefaultTableCellRenderer {

  private DefaultTableCellRenderer previousRenderer;

  public DecorateDefaultTableCellRenderer() {
    this.previousRenderer = new DefaultTableCellRenderer();
  }

  public DecorateDefaultTableCellRenderer(DefaultTableCellRenderer renderer) {
    this.previousRenderer = renderer;
  }

  @Override
  public Component getTableCellRendererComponent(JTable table, Object value,
          boolean isSelected, boolean hasFocus, int row, int column) {
    JLabel comp = (JLabel) previousRenderer.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
    return getTableCellRendererComponent(comp, table, value, isSelected, hasFocus, row, column);
  }

  public abstract Component getTableCellRendererComponent(JLabel comp, JTable table, Object value,
          boolean isSelected, boolean hasFocus, int row, int column);

  /**
   * @return the previousRenderer
   */
  public DefaultTableCellRenderer getPreviousRenderer() {
    return previousRenderer;
  }

  public void setPreviousCellRenderer(DefaultTableCellRenderer previousRenderer) {
    this.previousRenderer = previousRenderer;
  }
}
